package com.ww.java8.fp.stream.inaction.ch04;

import static com.ww.java8.fp.stream.inaction.ch04.Dish.menu;

import java.util.List;
import java.util.stream.Collectors;

public class HighCaloriesNames {

	/**
	 * 打印结果
	 * 过滤pork
	 * mapping pork
	 * 过滤beef
	 * mapping beef
	 * 过滤chicken
	 * mapping chicken
	 * [pork, beef, chicken]
	 * @param args
	 */
	public static void main(String[] args) {
		List<String> names = menu.stream()
		.filter(dish -> {
			System.out.println("过滤" + dish.getName());
			return dish.getCalories() > 300;
		})
		.map(dish -> {
			System.out.println("mapping " + dish.getName());
			return dish.getName();
		})
		// 截取前3个
		.limit(3)
		.collect(Collectors.toList());
		System.out.println(names);
	}
}
